package cn.edu.cqut.test0430;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Test2 {
	public static void main(String[] args) throws Exception  {
		File srcFile = new File("���ļ�.exe");
//		System.out.println(srcFile.getName());
		File destFile = new File("c:\\"+srcFile.getName());
		InputStream inputStream = new FileInputStream(srcFile);
		OutputStream outputStream = new FileOutputStream(destFile);
//		long startTime = System.currentTimeMillis();
//		int data;
//		//��ʱ��11395
//		while((data = inputStream.read())!=-1)
//		{
//			outputStream.write(data);
//		}
//		outputStream.flush();
//		outputStream.close();
//		inputStream.close();
//		long endTime = System.currentTimeMillis();
//		System.out.println("��ʱ��"+(endTime-startTime));
		
		long startTime = System.currentTimeMillis();
		byte[] data = new byte[1024];
		int len = -1;
		//��ʱ��17, 
		while((len = inputStream.read(data, 0, data.length))!=-1)
		{
			outputStream.write(data, 0, len);
		}
		outputStream.flush();
		outputStream.close();
		inputStream.close();
		long endTime = System.currentTimeMillis();
		System.out.println("��ʱ��"+(endTime-startTime));
	}
}
